package com.showde.shoppingmall.activity;

import java.util.ArrayList;

import com.showde.shoppingmall.utils.ActivityDispatch;

import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;

@SuppressWarnings("deprecation")
public class CategoryGroup extends BaseGroupActivity {

	private static final String TAG = "CategoryGroup";

	public static ActivityGroup group;
	private ArrayList<View> history;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		group = CategoryGroup.this;
		history = new ArrayList<View>();
	}

	@Override
	public void onBackPressed() {
		back();
		return;
	}

	@Override
	protected void onStart() {
		super.onStart();
		Intent intent = new Intent(this, CategoryActivity.class);
		Window w = group.getLocalActivityManager().startActivity(
				"PersonalCenterActivity", intent);
		View view = w.getDecorView();
		replaceView(view);
		group.setContentView(view);
	}

	public void replaceView(View v) {
		history.add(v);
		setContentView(v);
	}

	public void back() {
		if (history.size() > 1) {
			history.remove(history.size() - 1);
			View view = history.get(history.size() - 1);
			setContentView(view);
		} else {
			Log.d(TAG, "toHome");
			ActivityDispatch.toHome(this);
		}
	}
}
